<template>
	<div class="main"> 
		<!-- <scroller> -->
		<div class="adOuterWrap flex-h">
			<div class="back">
				<go-back aa='../teachers/teaindex'></go-back>
				<h2>生涯测评</h2>
			</div>
			<div class="adWrap">
				<div class="adBoxs">
				</div>
			</div>
			<div class="adBot">
				<span @click="gotos">进入生涯测评</span>
			</div>
		</div>
		<!-- </scroller> -->
	</div>
</template>
<script>
	import ls from 'store2';
	import {} from 'vux'
	import {
		format
	} from '~/plugins/filter';
	import goBack from '~/components/goBack'
	import axios1 from '~/plugins/axios1'
	export default {
		head: {
			title: '生涯测评'
		},
		components: {
			goBack
		},
		data() {
			return {
				toke: ''
			}
		},
		created() {
			this.commonJs.gologins();
			
		},
		mounted: function() {
			this.showNames();
			if(this.commonJs.isTerminal()=='isAndroid'){
			if (window.history && window.history.pushState) {
				history.pushState(null, null, document.URL);
				window.addEventListener('popstate', this.fun, false); //false阻止默认事件 
			}
			}

		},
		destroyed() {
			console.log('我离开了')
			// this.commonJs.xahui('../teachers/teaindex')
			window.removeEventListener('popstate', this.fun, false); //false阻止默认事件
		},
		watch: {

		},
		methods: {
			fun() {
				this.$router.replace({
					path: '../teachers/teaindex'
				
				})

			},
			showZongheList() {
				this.$vux.loading.show({text:"正在加载"});
				let userid = ls.get('userData').userId * 1;
				ls.set('userId', userid)
				let obj = {
					userId: ls.get('userData').userId * 1,
					userType: ls.get('userType') * 1
				}
				axios1.posts('/career/getReportList?userType=' + ls.get('userType') * 1).then(res => {
					if (res.code === '0' && res.data.length > 0) {
						this.reportCount = res.data.length;
						this.reportGen = res.data[0].generate;
						console.log('reportCount', this.reportCount)
						console.log('reportGen', this.reportGen)
						
					}
					this.$vux.loading.hide();
				}).catch(() => {
					this.$vux.loading.hide();
					this.$vux.toast.text('数据错误');
				})
			},
			goTestlogin() {
				ls.set('preUrl', '../evaluation/ad')
				// this.commonJs.gosto('../login/login');
			},
			gotos() {
				ls.set('preUrl', '../evaluation/ad')
				ls.set('preUrl', 'ad')
				if (this.reportCount > 1) {
					this.commonJs.gosto('reportRecord')

				} else if (this.reportCount == 1 && this.reportGen > 0) {
					this.commonJs.gosto('reportRecord')
				} else if (this.reportCount == 1 && this.reportGen == 0) {
					this.commonJs.gosto('evaluationEntry')
				} else {
					this.commonJs.gosto('evaluationEntry')
				}

			},
			goto(routerName, queryData) {
				this.$router.replace({
					path: routerName,
					query: {
						type: queryData
					}
				});
			},
			showNames() {

				let access = ls.get('userData') || ''
				access === '' ? this.toke = '' : this.toke = access.accessToken
				if (this.toke != '') {
					this.showZongheList()
				}

			}

		},
		beforeDestroy() {

		}

	}
</script>

<style scoped lang="less">
	.adOuterWrap {
		width: 7.5rem;
		height: 100vh;
		background: #fff;
		flex-direction: column;
		overflow: hidden;

		.adWrap {
			flex: 1;
			padding: 0 0.3rem;
			width: 7.5rem;
			box-sizing: border-box;

			.adBoxs {
				width: 100%;
				height: 100%;

				background: url('~/static/images/sybj.jpg') no-repeat;
				background-size: 100% 100%;

				img {
					display: block;
					border: none;
					width: 100%;
					height: 100%;
				}
			}
		}

		.adBot {
			span {
				display: block;
				width: 3.2rem;
				height: 0.88rem;
				background: linear-gradient(45deg, rgba(103, 189, 25, 1) 0%, rgba(181, 232, 97, 1) 100%);
				border-radius: 0.44rem;
				font-size: 0.36rem;

				font-weight: 600;
				color: rgba(255, 255, 255, 1);
				line-height: 0.88rem;
				text-align: center;
				margin: 0.2rem auto 0.3rem;

			}
		}
	}

	.back {
		width: 100%;
		height: auto;

		h2 {
			padding: 0 0.3rem;
			box-sizing: border-box;
			display: block;
			height: 0.8rem;
			font-size: 0.44rem;

			font-weight: bold;
			color: rgba(34, 34, 34, 1);
			line-height: 0.8rem;
		}
	}
</style>
